package com.tofine.smarthome.util;

import com.tofine.smarthome.model.Device;

/**
 * @author ddMax
 * @since 2016/5/30 15:52
 * 说明：设备命令执行工具类
 */
public class CommandUtils {

    public static boolean execute(Device device, String command) {
        if (command.equals("on")) {
            device.status = true;
        } else if (command.equals("off")) {
            device.status = false;
        }
        device.save();

        return device.status;
    }

    public static String genCommand(Device device) {
        return device.status ? "on" : "off";
    }
}
